package kandl.automation.steprunner.selenium.commands;


import kandl.automation.steprunner.selenium.Command;

import org.openqa.selenium.WebDriver;
import org.springframework.stereotype.Component;

@Component
class VerifyTitle implements Command {
    @Override
    public void runCommand(WebDriver driver, String... params) throws Exception {
        String expected = params[0];
        String actual = driver.getTitle();
        if (!actual.equals(expected)){
            throw new IllegalArgumentException("Expected title is expected to be '" + expected+ "' but got '" + actual + "'");
        }
    }

    @Override
    public String getName() {
        return "verify_title";
    }
}